The greatest example of all is the Great Wall of China.
It started out as a loose group of smaller walls, built in the 8th - 5th centuries BCE, the Spring and Autumn period, by small Chinese states to keep out the nomads of Inner Mongolia.
They were linked up and unified by Qin Shi Huang, first emperor of China, founder of the Qin dynasty.
Since then, the wall has deteriorated, been patched up again and extended.
The actual operational line of the wall was not static; during its lifetime its position shifted with state power and climate changes.
Most of the modern wall was built by the Ming dynasty in the 14th - 17th century CE.
It is so large that it can be seen from space.
Other examples are Hadrian's wall and the Antonine wall, both built in the 2th century CE by the Romans to keep out the Picts and Caledonians;
the Serpent's wall in the Ukraine, started in the 2nd century BCE and over 1,000 kilometers long;
the Danevirke between Denmark and Germany, used by the vikings and their descendants for centuries more;
and Offa's Dyke in the 8th century CE that marked the border between Mercia and Wales.
Even in recent times, in World War II, defensive walls were built,
like the French Maginot Line, the Soviet Stalin Line, the German Atlantikwall, all of which failed to stop invasions.
Early walls were usually earthen ramparts, sometimes with a palisade on top.
When the manpower of the state behind it grew, sections were built from brick and eventually stone.
Good walls are high, made from large blocks of stone and studded at regular intervals by watchtowers, barracks, stables and armories.
An example of a superb wall is the Maginot Line between France and Germany,
which was not just a wall but rather a 20 - 25 kilometer deep line of walls, ditches, bunkers and artillery,
effectively one 720 kilometers long fortress.
Construction of a border wall without machinery costs much labor, money and time.
The first version of the 118 kilometer long Hadrian wall took three legions 6 years to complete.
The Ming version of the Great Wall of China is about 8,850 kilometers long and was built up over decades.
The Maginot Line was built in 9 years and gobbled up most of France's defense budget.
Once a border wall is finished, it must be maintained and manned, by many soldiers.
Border walls, with the exception of massive fortifications like the Maginot Line, are too long to defend completely against an invading army.
Even stopping small parties of raiders is difficult.
But they mark the border clearly, show off the power of the state, hamper cattle rustling and can control immigration, trade and smuggling.
Despite their low military value, this seems to justify the effort to build and maintain them.
War Matrix - Border wall
Iron Age 1100 BCE - 550 BCE, Weapons and technology